package com.tinyseed.emcp.api.basicdata.model;

import com.tinyseed.emcp.api.basicdata.domain.Workshop;
import com.tinyseed.emcp.api.basicdata.domain.convert.DTOConvert;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.sql.Timestamp;

/**
 * Workshop
 *
 * @author tinyCode
 * @date 2019-11-22 21:37:55
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WorkshopOutputDTO implements Serializable {

    /**
     * 主键
     */
    private Long id;

    /**
     * 车间名称
     */
    private String shopName;

    /**
     * 企业id
     */
    private Long enterpriseId;

    /**
     * 备注
     */
    private String remark;

    /**
     * 创建时间
     */
    private Timestamp createTime;

    /**
     * 最后修改时间
     */
    private Timestamp modifyTime;

    /**
     * 创建人
     */
    private String creator;

    /**
     * 最后操作人
     */
    private String modifier;

    public Workshop convertToWorkshop() {
        WorkshopOutputDTOConvert convert = new WorkshopOutputDTOConvert();
        Workshop result = convert.convert(this);
        return result;
    }

    private static class WorkshopOutputDTOConvert implements DTOConvert<WorkshopOutputDTO, Workshop> {

        @Override
        public Workshop convert(WorkshopOutputDTO workshopOutputDTO) {
            Workshop workshop = new Workshop();
            BeanUtils.copyProperties(workshopOutputDTO, workshop);
            return workshop;
        }
    }

}
